package com.springCloud.demo;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import lombok.extern.java.Log;
import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName Demo
 * @Author 1628994918qq.com
 * @Date 2023/3/26 22:36
 */
@Slf4j
public class Demo {
    public static void main(String[] args) {

        String str = "{\n" +
                "    \"msg\": \"请求成功!CsmResponse(traceId=E-O.754869_sandbox.1011-20230326221235-4944f2, errorDescription=success, errorMessage=OK, errorCode=0, data={errorCode=0, errorMessage=查询成功, dataList=[{gdbm=CS20230325-004603, cp=62e8cd9f03a5a80001effc29, cljd=0, cjsj=2023-03-25 18:45}, {gdbm=CS20230325-004585, cp=62e8ca74aa05ba0001cdd5dd, cljd=0, cjsj=2023-03-25 16:21}, {gdbm=CS20230325-004579, cljd=0, cjsj=2023-03-25 11:28}, {gdbm=CS20230325-004580, cljd=0, cjsj=2023-03-25 13:54}, {gdbm=CS20230324-004552, cp=62e8ce932b034e00019d6a35, cljd=0, cjsj=2023-03-24 14:59}, {gdbm=CS20230315-004093, cp=62e8cbb253eac800017aaf50, cljd=0, cjsj=2023-03-15 17:27}, {gdbm=CS20230315-004057, cp=62e8cc81d22a1f00011470cf, cljd=0, cjsj=2023-03-15 14:50}]})\",\n" +
                "    \"code\": 0\n" +
                "}";

        JSONObject jsonObject = new JSONObject(Boolean.parseBoolean(str));
        JSONArray jsonArray = jsonObject.getJSONArray("msg");
        for (int j = 0; j < jsonArray.size(); j++) {
            JSONObject jsonObject2 = jsonArray.getJSONObject(j);
            String data = jsonObject2.getString("data");
            log.info("json------->",data);
        }
    }
}
